<form name="formCategoryEdit" id="formCategoryEdit" method="post" action="<?php echo $this->U('category', 'save'); ?>">

    <?php
    if (!empty($this->locales)) {
        foreach ($this->locales as $locale) {
            echo $this->formHidden('detailId['.$locale->localeId.']');
    ?>
            <div>
                <?php
                echo $this->formLabel('', 'Title (' . $locale->localeTitle) . ')';
                echo $this->formText('detailTitle['.$locale->localeId.']', '', array('maxlength' => 255, 'size' => '50'));
                ?>
            </div>
    <?php
        }
    }
    ?>

    <div>
        <label>Title in URL</label>
        <input type="text" name="categoryUrlTitle" id="categoryUrlTitle" class="input" value="" size="50" maxlength="255" tabindex="2" />
    </div>

    <div>
        <input type="hidden" id="categoryId" name="categoryId" value="" />
        <input type="submit" tabindex="2" value="Save" />
    </div>

</form>

<div class="cl" style="height:25px;">&nbsp;</div>

<?php
if (!empty($this->categories)) {
?>

    <div class="post_list">

        <table width="100%" border="0" cellspacing="5" cellpadding="0">
            <tr>
                <td class="list_head">No.</td>
                <td class="list_head">Title</td>
                <td class="list_head">Title in URL</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>

            <tr><td>&nbsp;</td></tr>

            <?php
            foreach ($this->categories as $category) {
                $categoryId = $category->categoryId;
                $categoryUrlTitle = $category->categoryUrlTitle;
            ?>

            <form name="formCategoryEdit[<?php echo $categoryId; ?>]" method="post" action="<?php echo $this->U('category', 'save'); ?>">
            <tr>
                <td class="list_content"><?php echo $categoryId; ?></td>
                <td class="list_content">
                    <table width="100%" cellpadding="0" cellspacing="0" border="0">
                    <?php
                    if (!empty($this->locales)) {
                        foreach ($this->locales as $locale) {
                            $detail = $category->fetchDetailByLocale($locale->localeId);
                            if (!empty($detail)) {
                                $detailId = $detail->detailId;
                                $detailTitle = $detail->detailTitle;
                            } else {
                                $detailId = '';
                                $detailTitle = '';
                            }
                    ?>
                        <tr>
                            <td>
                            <?php
                            echo $this->formHidden('detailId[' . $locale->localeId . ']',
                                                   $detailId,
                                                   array('maxlength' => 255, 'size' => '40'));

                            echo $this->formText('detailTitle[' . $locale->localeId . ']',
                                                 $detailTitle,
                                                 array('maxlength' => 255, 'size' => '40'));
                            ?>
                            </td>
                        </tr>
                    <?php
                        }
                    }
                    ?>
                    </table>
                </td>

                <td class="list_content">
                    <?php echo $this->formText('categoryUrlTitle', $categoryUrlTitle, array('maxlength' => 255, 'size' => '40')); ?>
                </td>

                <td class="list_content">
                    <?php echo $this->formSubmit('Save', 'Save'); ?>
                </td>

                <td class="list_content post_delete">
                    <?php echo $this->link($this->U('category', 'delete', 'admin', array('id' => $categoryId)), 
                                           $this->img('cross_red.jpg', '16', '16', 'delete'),
                                           false,
                                           array('onclick' => 'return confirm(\'' . $this->T('Do you really want to delete this category ? (' . $categoryUrlTitle . ')') . '\');'));
                    ?>
                </td>
                <?php echo $this->formHidden('categoryId', $categoryId); ?>
            </tr>
            </form>

            <tr><td>&nbsp;</td></tr>
            <?php
            }
            ?>

        </table>
    </div>

<?php } ?>